#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std; 

#define N 	500000

int ar[N], c[N]; 
int n; 
long long res; 

inline int read(void) {
    char ch;
    int num=0; 
	int sign=1;
	
	// skip blank character and get neigetive sign if it exist. 
    for (ch=getchar(); ch<'0'||ch>'9'; ch=getchar()) {
		if(ch=='-') {
			sign = -1;
		}
	}
	
    while(ch>='0' && ch<='9') {
		num = num*10 + (ch-'0'); 
		ch = getchar();
	}
    return sign*num; 
}

void merge_sort(int a, int b)
{
	int mid=(a+b)/2; 
	int i=a, j=(mid+1), k=a; 
	
	if (a>=b) {
		return;
	} 
	
	merge_sort(a, mid); 
	merge_sort(mid+1, b); 

	while(i<=mid && j<=b) {
		if (ar[i]<=ar[j]) {
			c[k++] = ar[i++]; 
		} else {
			c[k++] = ar[j++]; 

			// An example to understand the 'res' formula
			// [a, mid]: 2 4 5, [mid+1, b]: 1 3 6
			// now: i=0, j=mid+1, so we pop 1 and put it into c[], 
			// Since 1>[4, 5], so res+=2
			res += mid-i+1; 
		}
	}
	while(i<=mid) {
		c[k++] = ar[i++]; 
	}
	while(j<=b) {
		c[k++] = ar[j++]; 
	}
	for (k=a; k<=b; k++) {
		ar[k] = c[k]; 
	}
}

int main()
{
	int i; 
	
//	freopen("p1908.in", "r", stdin); 
	cin>>n; 
	for (i=0; i<n; i++) {
		ar[i] = read(); 
	}
	merge_sort(0, n-1); 

	cout<<res<<endl; 
	return 0; 
}

